﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Text;

public partial class Proccess_LoadVideoPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string modHost = ConfigurationManager.AppSettings["modHost"];
            int page = int.Parse(Request["page"]);
            int endrecore = (page * 3);
            int start = endrecore - 2;
            StringBuilder builder = new StringBuilder();
            List<DBAccess.Object.Subject> lstSubject = DBAccess.Business.SubjectBusiness.GetListAllSubjectVideosVisible(1, 2, start, endrecore);
            int totalRecordPage = 0;
            if (lstSubject != null && lstSubject.Count > 0)
            {
                string linkSubject = "";
                totalRecordPage = lstSubject.Count;
                string description = "", imageSubject = "";
                string title = "", author = "";
                int view = 1, comment = 1;
                int vt = 0;
                string createDate = "";
                foreach (DBAccess.Object.Subject subject in lstSubject)
                {
                    if (!string.IsNullOrEmpty(subject.Content))
                    {
                        description = HttpUtility.HtmlDecode(subject.Content);
                        description = description.Replace("<p>", "").Replace("</p>", "");
                    }
                    author = subject.AuthorName;
                    view = subject.TotalView;
                    comment = subject.TotalComment;
                    imageSubject = modHost + subject.ImagePath;
                    createDate = Utilitys.ConvertToTimeVietName(subject.CreateDate);
                    linkSubject = Utilitys.sefSubjectLink(subject.ID, subject.Title);

                    builder.Append("<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12\">");
                    builder.Append("<div class=\"videobox2 blogposttwo\">");
                    builder.Append("<div class=\"text title-def\">");
                    builder.Append("<h2><a href=\"" + linkSubject + "\">" + title + "</a></h2>");
                    builder.Append("<ul class=\"tip-info\">");
                    builder.Append("<li><i class=\"fa fa-user\"></i> <strong>" + author + "</strong> <small>" + createDate + "</small> </li>");
                    builder.Append("<li><i class=\"fa fa-eye\"></i><strong>" + view + "</strong> <small>lượt xem</small></li>");
                    builder.Append("<li><i class=\"fa fa-comments\"></i><strong>" + comment + "</strong> <small>thích</small></li>");
                    builder.Append("</ul>");
                    builder.Append("</div>");

                    builder.Append("<figure>");
                    builder.Append("<a href=\"" + linkSubject + "\" target=\"_blank\" title=\"" + subject.Title + "\">");
                    if (subject.TypeSubject == 2)
                    {
                        builder.Append("<img src=\"" + imageSubject + "\" style=\"width:564px; height:390px\" />");
                    }
                    else
                    {

                        builder.Append("<img src=\"" + imageSubject + "\" style=\"width:564px;\" />");

                    }

                    builder.Append("</a>");
                    builder.Append("</figure>");

                    if (subject.TypeSubject == 2)
                    {

                        builder.Append("<a href=\"" + linkSubject + "\" target=\"_blank\" title=\"" + subject.Title + "\" style=\"float:left\">");
                        builder.Append("<div class=\"iconPlay\"></div>");
                        builder.Append(" </a>");

                    }

                    builder.Append("<div class=\"text\">");

                    builder.Append("<div style=\"float:left; width:50%; padding-top:12px;\"><div class=\"fb-like\" data-href=\"" + linkSubject + "\" data-layout=\"button_count\" data-action=\"like\" data-show-faces=\"true\" data-share=\"true\"></div></div>");

                    builder.Append("<a href=\"javascript:;\" onclick=\"ShowFormCommet('" + subject.ID + "')\" class=\"btn btn-primary backcolor alignright\"><i class=\"fa fa-group\">&nbsp;</i>Bình Luận</a>");
                    builder.Append("</div>");
                    builder.Append("<div class=\"text\" id=\"divComment" + subject.ID + "\" style=\"display:none\">");
                    builder.Append("<div class=\"fb-comments\" data-href=\"" + linkSubject + "\" data-numposts=\"3\" data-colorscheme=\"light\"></div>");
                    builder.Append("</div>");

                    builder.Append("</div>");
                    builder.Append("<div class=\"clearfix\"></div>");
                    builder.Append("<hr />");
                    builder.Append("</div>");


                }
                Response.Write(builder);
            }
            Response.End();
        }
        catch
        {

        }
    }
}